package org.sgx.gwteditors.testgallery.gallery.app;

import java.util.LinkedList;
import java.util.List;

import org.sgx.gwteditors.client.editor.Editor;
import org.sgx.gwteditors.client.editor.props.PropertyHaver;
import org.sgx.gwteditors.client.impl1.EditorFramework1;
import org.sgx.gwteditors.client.impl1.complex.PropertyHaverEditor1;
import org.sgx.gwteditors.client.impl1.complex.SelectionListMultipleSelEditor;
import org.sgx.gwteditors.client.impl1.complex.SelectionListSingleSelEditor;
import org.sgx.gwteditors.client.impl1.misc.HTML5FileEditor;
import org.sgx.gwteditors.client.impl1.misc.ImageUrlEditor;
import org.sgx.gwteditors.client.impl1.misc.LinkEditor;
import org.sgx.gwteditors.client.impl1.misc.PasswordEditor;
import org.sgx.gwteditors.client.impl1.misc.RichTextEditor;
import org.sgx.gwteditors.client.impl1.simple.BooleanEditor;
import org.sgx.gwteditors.client.impl1.simple.ColorEditor;
import org.sgx.gwteditors.client.impl1.simple.DateEditor;
import org.sgx.gwteditors.client.impl1.simple.DateTimeEditor;
import org.sgx.gwteditors.client.impl1.simple.DoubleEditorEntry;
import org.sgx.gwteditors.client.impl1.simple.InRangeDoubleEditor;
import org.sgx.gwteditors.client.impl1.simple.InRangeIntegerEditor;
import org.sgx.gwteditors.client.impl1.simple.IntegerEditorEntry2;
import org.sgx.gwteditors.client.impl1.simple.TimeEditor;
import org.sgx.gwteditors.testgallery.gallery.BeanEditorTest1;
import org.sgx.gwteditors.testgallery.gallery.Test;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleDateAndTimeEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleBooleanEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleColorEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleDateEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleDoubleEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleHTML5FileEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleImageUrlEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleInRangeDoubleEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleInRangeIntegerEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleIntegerEditorEntry2Test;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleIntegerEditorEntryTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleLinkEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimplePasswordEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleRichTextEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleSelectionListMultipleSelEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleSelectionListSingleSelEditorTest;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleStringEditorEntry;
import org.sgx.gwteditors.testgallery.gallery.simple.SimpleTimeEditorTest;

import com.google.gwt.resources.client.ExternalTextResource;

/**
 * some descriptive information about each supported editor.
 * 
 * @author sg
 * 
 */
public class EditorMetainfo {
	
//	Map<String, MetaInfo> info; 
	List<MetaInfo> infos;
	
	public EditorMetainfo() {
		
		new EditorFramework1().start();
		infos=new LinkedList<EditorMetainfo.MetaInfo>(); 
//		info = new HashMap<String, MetaInfo>();		  
//		String name = null, description=null, type=null, id=null; 	
//		Test test=null;
		MetaInfo info = null;

		//base editors
		info = new MetaInfo();
		info.setName("String editor"); 
		info.setDescription("A simple String editor that uses a text entry"); 
		info.setSimpleTest(new SimpleStringEditorEntry()); 
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Integer editor 1"); 
		info.setDescription("A simple Integer editor that shows a text entry"); 
		info.setSimpleTest(new SimpleIntegerEditorEntryTest()); 
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Integer editor 2"); 
		info.setDescription("A simple Integer editor that shows a text entry and incrementor buttons"); 
		info.setSimpleTest(new SimpleIntegerEditorEntry2Test());
		info.setEditor(new IntegerEditorEntry2());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Boolean editor"); 
		info.setDescription("A simple Boolean editor that shows a checkbox"); 
		info.setSimpleTest(new SimpleBooleanEditorTest());
		info.setEditor(new BooleanEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Color editor"); 
		info.setDescription("A simple Color editor that shows colored text input with hex and let the user choose the color with a colorpicker when the text is clicked."); 
		info.setSimpleTest(new SimpleColorEditorTest()); 
		info.setEditor(new ColorEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Date editor"); 
		info.setDescription("A simple DateEditor using GWT DateEntry Widget - a text entry that when clicked will drop down a calendar"); 
		info.setSimpleTest(new SimpleDateEditorTest());
		info.setEditor(new DateEditor()); 
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Time editor"); 
		info.setDescription("Using the artificial type Time for representing times (hour, minute, seconds) and the TimeEditor that will present with input boxes to the user. "); 
		info.setSimpleTest(new SimpleTimeEditorTest());
		info.setEditor(new TimeEditor()); 
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Date & Time editor"); 
		info.setDescription("A simple Date and time editor using GWT DateTimeEditor"); 
		info.setSimpleTest(new SimpleDateAndTimeEditorTest());
		info.setEditor(new DateTimeEditor()); 
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Double editor"); 
		info.setDescription("A simple double editor text entry"); 
		info.setSimpleTest(new SimpleDoubleEditorTest());
		info.setEditor(new DoubleEditorEntry());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("In Range Double editor"); 
		info.setDescription("A editor for the datatype InRangeDouble - representing a double between other two numbers. Shows the user a slider for choosing the value. "); 
		info.setSimpleTest(new SimpleInRangeDoubleEditorTest());
		info.setEditor(new InRangeDoubleEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("In Range Integer editor"); 
		info.setDescription("A editor for the datatype InRangeInteger - representing an integer between other two numbers. Shows the user a slider for choosing the value. "); 
		info.setSimpleTest(new SimpleInRangeIntegerEditorTest()); 
		info.setEditor(new InRangeIntegerEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("SelectionListSingleSel editor"); 
		info.setDescription("An editor for SelectionList<T> - a list item chooser in this case allowing only a single item selection - shows the user a combobox widget"); 
		info.setSimpleTest(new SimpleSelectionListSingleSelEditorTest()); 
		info.setEditor(new SelectionListSingleSelEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("SelectionListMultipleSel editor"); 
		info.setDescription("An editor for SelectionList<T> - a list item chooser in this case allowing multiple item selection - shows the user a html item list widget"); 
		info.setSimpleTest(new SimpleSelectionListMultipleSelEditorTest());
		info.setEditor(new SelectionListMultipleSelEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("Rich Text Editor"); 
		info.setDescription("A rich text editor - this will let the user edit an rich text in HTML format (String). "); 
		info.setSimpleTest(new SimpleRichTextEditorTest()); 
		info.setEditor(new RichTextEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("LinkEditor"); 
		info.setDescription("A Link editor, this is an String editor that shows a link and optionally let the user edit the string. "); 
		info.setSimpleTest(new SimpleLinkEditorTest()); 
		info.setEditor(new LinkEditor());
		infos.add(info); 
		
		info = new MetaInfo();
		info.setName("ImageUrlEditor"); 
		info.setDescription("An image editor, this is an Url String editor that shows an image and optionally let the user edit the url."); 
		info.setSimpleTest(new SimpleImageUrlEditorTest()); 
		info.setEditor(new ImageUrlEditor());
		infos.add(info);
		
		info = new MetaInfo();
		info.setName("PasswordEditor"); 
		info.setDescription("An string editor for passwords"); 
		info.setSimpleTest(new SimplePasswordEditorTest()); 
		info.setEditor(new PasswordEditor());
		infos.add(info);
		
		info = new MetaInfo();
		info.setName("HTML5FileEditor"); 
		info.setDescription("An editor that let the user choose native files dragging and droping them from Desktop"); 
		info.setSimpleTest(new SimpleHTML5FileEditorTest()); 
		info.setEditor(new HTML5FileEditor());
		infos.add(info);
		
		info = new MetaInfo();
		info.setName("PropertyHaverEditor1"); 
		info.setDescription("A PropertyHaver editor, in this case using the EditableBean type we work using a Java Bean. "); 
		info.setSimpleTest(new BeanEditorTest1()); 
		info.setEditor(new PropertyHaverEditor1<PropertyHaver>());
		infos.add(info); 
		
//		info = new MetaInfo();
//		info.setName("PropertyHaverEditor2"); 
//		info.setDescription("A PropertyHaver editor, in this case using the EditableBean type we work using a Java Bean. The difference between PropertyHaverEditor1 and PropertyHsverEditor2 is that the later will also let edit complex attributes. In this case a person is related to another person via the 'mother' attribute. The editor will show a text entry for that attribute that when clicked will show an editor for the attribute in a dialog box. "); 
//		info.setSimpleTest(new BeanEditorTest2()); 
//		info.setEditor(new array1ded<PropertyHaver>());
//		infos.add(info); 
		
	}
	
	public List<MetaInfo> getInfos() {
		return infos;
	}	
	
	public static class MetaInfo {
		String name, id, description, type;
		Boolean complex;
		Test simpleTest;
		List<Test> tests;
		Editor editor;
//		ExternalTextResource source;
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getDescription() {
			return description;
		}
		public void setDescription(String description) {
			this.description = description;
		}
		public String getType() {
			return type;
		}
		public void setType(String type) {
			this.type = type;
		}
		public Boolean getComplex() {
			return complex;
		}
		public void setComplex(Boolean complex) {
			this.complex = complex;
		}
		public List<Test> getTests() {
			return tests;
		}
		public void setTests(List<Test> tests) {
			this.tests = tests;
		}
		public String getId() {
			return id;
		}
		public void setId(String id) {
			this.id = id;
		}
		public Test getSimpleTest() {
			return simpleTest;
		}
		public void setSimpleTest(Test simpleTest) {
			this.simpleTest = simpleTest;
		}
		public ExternalTextResource getSource() {
			if(simpleTest.getJavaSources()!=null && simpleTest.getJavaSources().values()!=null && simpleTest.getJavaSources().values().size()>0) 
				return simpleTest.getJavaSources().values().iterator().next();			
			else
				return null;
		}
		public Editor getEditor() {
			return editor;
		}
		public void setEditor(Editor editor) {
			this.editor = editor;
		}
		
	}
	
}
